package com.nl.countdownclock.client;
import com.nl.countdownclock.client.PhysicalEnsemble;
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.canvas.dom.client.Context2d;
import java.util.ListIterator;

public class PhysicalEnsembleView {
	Canvas canvas;
	PhysicalEnsemble pe;
	Context2d ctx;
	
	public PhysicalEnsembleView(Canvas canvas, PhysicalEnsemble pe){
		this.canvas = canvas;
		this.pe = pe;
		this.ctx = canvas.getContext2d();
	}
	public void draw(){
		ListIterator<Ball> balls = pe.getIterator();
		while(balls.hasNext()){
			Ball b = balls.next();
			ctx.setFillStyle(b.color);
			ctx.beginPath();
			ctx.arc(b.x,b.y,b.radius,0,Math.PI*2,true);
			ctx.closePath();
			ctx.fill();	
			}
		}

}
